/*
 * File:   MessageCounter.java
 * Author: Oleg S. Estekhin
 */
package dht.emulator.filters;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import dht.emulator.Identifier;
import dht.emulator.Node;

/** todo write javadoc for MessageCounter. */
public class GlobalMessageCounter extends FilterNode
{

    private final AtomicInteger counter;


    public GlobalMessageCounter(Node delegate, AtomicInteger counter)
    {
        super(delegate);
        this.counter = counter;
    }


    @Override
    public int getQuality(Node sender)
    {
        counter.incrementAndGet();
        return super.getQuality(sender);
    }

    @Override
    public List<Node> getNodes(Identifier identifier, Node sender)
    {
        counter.incrementAndGet();
        return super.getNodes(identifier, sender);
    }

    @Override
    public String getValue(Identifier key, Node sender)
    {
        counter.incrementAndGet();
        return super.getValue(key, sender);
    }

    @Override
    public void putValue(Identifier key, String value, Node sender)
    {
        counter.incrementAndGet();
        super.putValue(key, value, sender);
    }

}